<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/inc/common.jsp"%>
<html>
<head>
<title>终检亭入境放行卡</title>

<script type="text/javascript">
$(document).ready(function () {
	var carNo = $("#carNo").textbox('getValue');
	loadPic(carNo);
	var entryTime = "${cardRelease.entryTime}";
	if(entryTime == null || entryTime == ""){
		$("#entryTime").datetimebox("setValue",dtbInitDate(new Date()));
	}
		//计算总数
		$('#chineseNum').textbox('textbox').bind('blur', function() {  
			var num1 = $("#chineseNum").textbox('getValue'); //获取第一个输入框的值
			var num2 = $("#foreignNum").textbox('getValue');  //获取第二个输入框的值
			if(num1 != null && num1 != ""){
			    num1 = parseInt(num1);  //转换为整数
			}else{
				num1 = 0;
			}
			if(num2 != null && num2 != ""){
				num2 = parseInt(num2);  //转换为整数
			}else{
				num2 = parseInt(0);
			}
		    $("#totalNum").textbox('setValue',num1 + num2);
	     });
		
		$('#foreignNum').textbox('textbox').bind('blur', function() {  
			var num1 = $("#chineseNum").textbox('getValue'); //获取第一个输入框的值
			var num2 = $("#foreignNum").textbox('getValue');  //获取第二个输入框的值
			if(num1 != null && num1 != ""){
			    num1 = parseInt(num1);  //转换为整数
			}else{
				num1 = 0;
			}
			if(num2 != null && num2 != ""){
				num2 = parseInt(num2);  //转换为整数
			}else{
				num2 = 0;
			}
		    $("#totalNum").textbox('setValue',num1 + num2);
	     }); 
	
	//回车保存
	$(document).keydown(function(e){
		if(e.keyCode == 13) {
			saveDate();
		}
	});
});
	
	//防止二次提交
	var submitState = true;
	function saveDate(){
		var isValid = $("#editForm").form('validate');
		if(submitState && isValid){
			submitState = false;
			doSave();
		}
	}
	function doSave(){
		var record=form2Json('editForm');
		$.ajax({
			type : 'post',
			url :  '${basePath}/bus/enterCard/save.do?type='+'${type}',
			data : "data="+JSON.stringify(record),
			dataType:"json",
			success : function(msg) {
				$.each(msg,function(i,n){
            		if(n.message == "success"){
            			$.messager.alert("消息", "保存成功！");
            			setTimeout(function () {
            				window.location.href="${basePath}/bus/enterCard/index.do?type="+"${type}";
            			}, 1000);
            		}else{
            			$.messager.alert('消息', n.errMsg);
            		}
               });
			}
		});
	}
	
	//导入图片
	function loadPic(carNo){
		$.ajax({
			type : 'post',
			url :  '${basePath}/bus/enterCard/loadPic.do',
			data : "carNo="+carNo,
			dataType:"json",
			success : function(msg) {
				$.each(msg,function(i,n){
            		if(n.message == "success"){
            			$("#zm").attr('src','${basePath}'+n.zm);
            			$("#zm").attr('jqimg','${basePath}'+n.zm);
            			$("#hm").attr('src','${basePath}'+n.hm);
            			$("#hm").attr('jqimg','${basePath}'+n.hm);
            			$("#cq").attr('src','${basePath}'+n.cq);
            			$("#cq").attr('jqimg','${basePath}'+n.cq);
            			$("#ch").attr('src','${basePath}'+n.ch);
            			$("#ch").attr('jqimg','${basePath}'+n.ch);
            			$("#showState").val("2");
            			$("#picTable").show();
            		}else if(n.message == "error"){
            			$("#showState").val("1");
            			$("#picTable").hide();
            		}else{
            			$("#showState").val("1");
            			$("#picTable").hide();
            			$.messager.alert('消息', n.errMsg);
            		}
               });
			}
		});
	}
</script>
</head>
<body class="easyui-layout" data-options="fit:true">
	<div  data-options="region:'center',title:'放行卡信息',footer:'#searchfooter'" >
		<div class="easyui-layout" data-options="fit:true" >
			<div data-options="title:'',region:'west'," style="width:30%;">
				<div class="easyui-panel" data-options="title:'',fit:true"  style="padding:5px 5px 5px 5px;"  border=false>
				    <form id="editForm"  method="post">
				    	<input id="id" name="id" type="hidden" value="${cardRelease.id}">
				    	<table  style="width:100%;" cellpadding="0" cellspacing="1"  class="formtable">
				    		<tr>
								<td align="right" style="width: 30%">流水号:</td>
								<td class="value">
								<input class="easyui-textbox" type="text" id="serialNo" name="serialNo" value="${cardRelease.serialNo}" readonly >
								</td>
							</tr>
							<tr>
								<td align="right">车牌号:</td>
								<td class="value">
								<input class="easyui-textbox" type="text" name="carNo" id="carNo" value="${cardRelease.carNo}" data-options="required:true" >
								</td>
							</tr>
							<tr>
								<td align="right">中国旅客人数:</td>
								<td class="value">
								<input class="easyui-textbox" type="text" name="chineseNum" id="chineseNum" value="${cardRelease.chineseNum}" data-options="required:true">
								</td>
					    	</tr>
							<tr>
								<td align="right">外国旅客人数:</td>
								<td class="value">
								<input class="easyui-textbox" type="text" name="foreignNum" id="foreignNum" value="${cardRelease.foreignNum}" data-options="required:true">
								</td>
							</tr>
							<tr>
								<td align="right">总人数:</td>
								<td class="value">
								<input class="easyui-textbox" type="text" name="totalNum" id="totalNum" value="${cardRelease.totalNum}" readonly>
								</td>
							</tr>
							<tr>
								<td align="right">国籍:</td>
								<td class="value">
								<input class="easyui-combobox" type="text" name="nationality" id="nationality" value="${cardRelease.nationality}" data-options="url:'${basePath}/sys/dictionary/dicbykey.do?key=1005',method:'get',valueField:'dataCode',textField:'dataName',panelHeight:'auto',editable:false,required:true" >
								</td>
					    	</tr>
							<tr>
								<td align="right">入境时间:</td>
								<td class="value">
								<input class="easyui-datetimebox" type="text" id="entryTime" name="entryTime" value="${entryTime}" readonly>
								</td>
							</tr>
							<tr>
								<td align="right">车辆类型:</td>
								<td class="value">
								<input class="easyui-combobox" type="text" name="carType" id="carType" value="${cardRelease.carType}" data-options="url:'${basePath}/sys/dictionary/dicbykey.do?key=1009',method:'get',valueField:'dataCode',textField:'dataName',panelHeight:'auto',editable:false,required:true" >
								</td>
							</tr>
							<tr>
								<td align="right">出入境类型:</td>
								<td class="value">
								<input class="easyui-combobox" type="text" name="entryExitType" id="entryExitType" value="101101" data-options="url:'${basePath}/sys/dictionary/dicbykey.do?key=1011',method:'get',valueField:'dataCode',textField:'dataName',panelHeight:'auto',editable:false,required:true" readonly>
								</td>
					    	</tr>
					    	<tr>
								<td align="right">备注:</td>
								<td class="value">
								<input id="remark" name="remark" class="easyui-textbox" value="${cardRelease.remark}" data-options="multiline:true" data-options="validType:'maxLength[150]'" style="height: 60px;"></input>
								</td>
					    	</tr>
				    	</table>
				    </form>
				</div>
			</div>
			<!--图片展示  -->
			<div data-options="region:'center'" >
				<div class="easyui-panel" data-options="title:'',fit:true"  style="padding:5px 5px 5px 5px;"  border=false>
			    	<table id="picTable" style="width:100%;" cellpadding="0" cellspacing="1" class="formtable">
			    		<tr>
			    			<td align="center" style="width: 15%">正面</td>
			    			<td class="value">
		    					<div class="jqzoomright">
 									<img id="zm" class="sampleimage" src="" jqimg="" />
								</div>
			    			</td>
			    			<td align="center" style="width: 15%">侧后面45度</td>
			    			<td class="value">
		    					<div  class="jqzoomleft">
 									<img id="ch" class="sampleimage" src="" jqimg="" />
								</div>
			    			</td>
			    		</tr>
			    		<tr>
			    			<td align="center">侧前45度</td>
			    			<td class="value">
		    					<div  class="jqzoomright">
									<img id="cq" class="sampleimage" src="" jqimg="" />
								</div>
			    			</td>
			    			<td align="center">后面</td>
			    			<td class="value">
		    					<div  class="jqzoomleft">
									<img id="hm" class="sampleimage" src="" jqimg=""/>
								</div>
			    			</td>
			    		</tr>
			    	</table>
				</div>
			</div>
		</div>
	</div>
	<!-- 保存按钮 -->
	<div id="searchfooter" style="text-align:right;padding: 0px 10px">
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="saveDate()" data-options="iconCls:'icon-page_save',plain:true" >保存并放行</a>
		<span class="search-btn-separator"></span>
		<a href="javascript:history.go(-1)" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true">返回</a>
	</div>
</body>
<!--jqzoom css  -->
<link rel="stylesheet" type="text/css" href="${basePath}/css/pic/jqzoom.css" />
<!--jqzoom js  -->
<script type="text/javascript" src="${basePath}/js/pic/jquery.jqzoom.js" ></script>
<script type="text/javascript" src="${basePath}/js/pic/jqzoom.init.js" ></script>
</html>
